package gui;


import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;


/**
 * @author aioros
 * cero project repository gui  (singleton)
 */
public class CeroRepositoryClient extends JFrame {

	/*-------------------- Fields -----------------------------*/

	private static final long serialVersionUID = 1578698909L;
	
	/**
	 * the single object MainFrame
	 */
	private static CeroRepositoryClient ceroRepositoryClient = new CeroRepositoryClient();
	
	
	
	/*-------------------- Constructor ------------------------*/

	/**
	 * the constructor is private in order to create a singleton
	 */
	private CeroRepositoryClient(){
		super();
		
		this.initialize();
		
		/* JXTable area */
		JScrollPane packagesjTbl = new JScrollPane(PackagesJXTable.getPackagesJXTable());
		packagesjTbl.setBounds(0, 0, 990, 300);
		
		/* action area */
		ActionContainer actionContainer = ActionContainer.getActionContainer();
		actionContainer.setBounds(0, 310, 990, 90);
		
		/* Description area */
		JLabel packageDescription = new JLabel("Package Description : ");
		packageDescription.setBounds(10, 420, 150, 25);
		JScrollPane descriptionJLabel = new JScrollPane(DescriptionJLabel.getDescriptionJLabel());
		descriptionJLabel.setBounds(0, 450, 990, 300);
		descriptionJLabel.setBackground(Color.WHITE);

		Container mainContainer = this.getContentPane();
		mainContainer.setLayout(null);
		
		mainContainer.add(packagesjTbl);
		mainContainer.add(actionContainer);
		mainContainer.add(packageDescription);
		mainContainer.add(descriptionJLabel);
		
		this.pack();
		this.setVisible(true);
	}
	
	
	/*-------------------- Methodes ---------------------------*/
	
	
	/**
	 * property frame initialize 
	 */
	private void initialize() {
		
		this.setTitle("Cero Project Repository");
		this.setSize(1000, 800);
		this.setPreferredSize(new Dimension(1000, 800));
		this.setResizable(false);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		Dimension tailleEcran = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
		this.setLocation(	(int) (tailleEcran.getWidth()- this.getWidth())/2,
				(int) (tailleEcran.getHeight()- this.getHeight())/2 );
		ImageIcon logosmall = new ImageIcon("ressources/images/logosmall.png");
		this.setIconImage(logosmall.getImage());
	}
	
	
	/**
	 * @return the single object MainFrame
	 */
	public static CeroRepositoryClient getCeroRepositoryClient(){
		
		return ceroRepositoryClient;
	}
}
